<?php

namespace App\Http\Middleware;

use App\Models\Websiteconfig;
use Closure;
use Encore\Admin\Facades\Admin;
use Illuminate\Support\Facades\Auth;

class CheckGoogleAuth
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        $user = Auth::user();

        // 商户和普通用户直接登录
        if($user->user_type != 'admin') {
            return $next($request);
        }


        if($request->session()->get("ga", 0) == 1) {
            return $next($request);
        }

        return redirect()->route('valid_login_google');
    }
}
